package logic

import (
	"context"
	"user_srv/internal/dao"
	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type IsBitmapSignedLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewIsBitmapSignedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *IsBitmapSignedLogic {
	return &IsBitmapSignedLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *IsBitmapSignedLogic) IsBitmapSigned(in *user.IsBitmapSignedRequest) (*user.IsBitmapSignedResponse, error) {
	// 调用 dao 层的 IsBitmapSigned 方法
	signed, err := dao.IsBitmapSigned(in.UserId)
	if err != nil {
		return &user.IsBitmapSignedResponse{
			Signed: false,
		}, err
	}

	return &user.IsBitmapSignedResponse{
		Signed: signed,
	}, nil
}
